


<div id="main" class="settings col-md-10 form-horizontal">
    <form id="setting" action="{:U('home/user/checkmail')}" method="post">
        
        <div class="form-group mt15">
            <label for="setting-mail" class="required control-label col-sm-2">
                新 Email 地址
            </label>
            <div class="col-sm-8">
                <input name="mail" id="setting-mail" type="mail" placeholder="hello@segmentfault.com"
                class="form-control mono" autocomplate="false" required="">
                <p id="showerror2"></p>
                
            </div>
        </div>
        <div class="form-action row">
            <div class="col-sm-10 col-sm-offset-2">
                <button class="btn btn-xl btn-primary mail-sub">
                    提交
                </button>
            </div>
        </div>
       
    </form>
</div>
<script type="text/javascript">
    $(function() {
            $('#setting-mail').blur(function(event) {
                value = $(this);
                data = $(this).val();
                $.ajax({
                    url: '{:U("home/login/checkmail")}',
                    type: 'POST',
                    dataType: 'json',
                    data: {mail: data},
                })
                .done(function(data) {
                    if (data.error==1) {
                        value.parent().addClass('has-error');
                        value.siblings('#showerror2').html('<span class="help-block err">'+data.info+'</span>')
                    }else{
                        value.parent().removeClass('has-error');
                        $('#showerror2').html('<span>'+data.info+'</span>')
                    }
                })
            });
        });
</script>

</div>
</div>
</div>